﻿// ===============================================================================
// XCI.Parent 西安交通信息WinForm开发框架 2019 版权所有
// ===============================================================================

using System;
using System.Windows.Forms;
using XCI.Core;
using XCI.Windows;

namespace XCI.Sys.Forms
{
    public partial class FrmUnLock : BaseForm
    {
        public FrmUnLock()
        {
            InitializeComponent();
        }

        private bool IsExit { get; set; }

        private void btnUnLock_Click(object sender, EventArgs e)
        {
            //Todo 账户解锁
            //string account = SysRuntime.CurrentUser.Account;
            //string password = editPassword.Text;
            //if (string.IsNullOrEmpty(password))
            //{
            //    MessageBoxHelper.ShowWarn("请输入密码");
            //    editPassword.Select();
            //    return;
            //}

            //var captcha = string.Empty;
            //var reqCap = AccountService.Instance.requireCaptcha(account);
            //if (reqCap)
            //{
            //    SplashHelper.ShowWait("正在生成验证码...", this);
            //    var capForm = new FrmCaptcha(account);
            //    capForm.ShowDialog();
            //    captcha = capForm.Captcha;
            //    capForm.Dispose();
            //}

            //var result = SysRuntime.Instance.UserValid(account, password, captcha);
            //if (result.Success)
            //{
            //    IsExit = true;
            //    this.DialogResult = DialogResult.OK;
            //}
            //else if (!string.IsNullOrEmpty(result.Msg))
            //{
            //    MessageBoxHelper.ShowError(result.Msg);
            //}
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Startup.Kill();
        }

        private void UnLockMainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = !IsExit;
        }

        private void FrmMainUnLock_Load(object sender, EventArgs e)
        {
            //this.captionControl1.CaptionText = string.Format("当前用户:{0}",
            //    CurrentUser.Name);
            //NativeMethods.SetForegroundWindow(this.Handle);
        }
    }
}